package org.command.main.CS3;

public class Contact {
    private String name;
    private String address;
    private String phone;

    public Contact() {
    }

    public Contact(String name, String address, String phone) {
        this.name = name;
        this.address = address;
        this.phone = phone;
    }
    // 从字符串创建Contact对象
    public static Contact fromString(String contactString) {
        String[] parts = contactString.split(",");
        if (parts.length == 3) {
            String name = parts[0];
            String address = parts[1];
            String phone = parts[2];
            return new Contact(name, address, phone);
        } else {
            throw new IllegalArgumentException("Invalid contact string format");
        }
    }
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    @Override
    public String toString() {
        return "Contact{" +
                "name='" + name + '\'' +
                ", phone='" + phone + '\'' +
                ", address='" + address + '\'' +
                '}';
    }
}
